The mvc html begin form link to the action method of the controller that renders the form. The Html helper BeginForm has several overrides.
The below example uses four parameters such as the name of the action method, controller to submit the form, routevalues attribute and form method.
Mvc Html BeginForm example: (with area)
@using (@Html.BeginForm("Create", "Category", new { area = "admin" }, FormMethod.Post))
{
@Html.Partial("_Category", Model)
}
Here, the controller that renders the form is Category, Action method is created and area is Admin. If you want to go different area, then modify the area field and set new area.
Without area:
@using (@Html.BeginForm("index", "Home", new { area = "" }, FormMethod.Post))
{
// call the controller
}
If you want access the home controller, outside the Areas from the admin area you should specify the empty quotes for the parameter.
what is an area in asp.net mvc and how to implement? for more detail link here
Post your comments / questions
Recent Article
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
- ImportError: cannot import name 'url' from 'django.conf.urls' - Django Error
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
Related Article